/*	
	stencil - action script 3 isometric game engine.

	http://code.google.com/p/stencilas3/
	
	Copyright (c) 2010 Max Zhuravkov, All Rights Reserved.

	Permission is hereby granted, free of charge, to any person obtaining a copy of
	this software and associated documentation files (the "Software"), to deal in
	the Software without restriction, including without limitation the rights to
	use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
	of the Software, and to permit persons to whom the Software is furnished to do
	so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
package stencil.core.engine 
{
	
	/**
	 * 
	 * 
	 * @author Max Zhuravkov
	 */
	public interface IObjectFactory {
		
		/**
		 * The base type of all object that this factory creates.
		 */
		function get genericType():Class;
		
		/**
		 * Registers the component type using the specified alias. If the component type alias is already exists ArgumentError is thrown
		 * @param	type	the compoent type alias.
		 * @param	componentClass	the component class. 
		 * @param	propeties	the map of properties.
		 * 
		 */
		function addComponentType(type:String, componentClass:Class, properties:Object = null):void;
		
		/**
		 * Unregisters the component type with specified alias. If no component type with such alias registered ArgumentError is thrown.
		 * 
		 * @param	type	the component type alias.
		 */
		function removeComponentType(type:String):void;
		
		/**
		 * Registers the object type using the specified type alias. If the object type alias is already exists ArgumentError is thrown
		 * 
		 * @param	type	the object type alias.
		 * @param	objectClass	the object class.
		 * @param	propeties	the map of properties.
		 * @param	components	the map of components (Identifier to Component type alias or Indetifier to Component Class). Represents the set of components to be attached to instances of this object type. Note: in order to components to be added to instances of the given object type the type should implement IComponentList interface. 
		 */
		function addObjectType(type:String, objectClass:Class, properties:Object = null, components:Object = null):void;
		
		/**
		 * Unregisters display object class with the specified type alias. If no display object class found for the specified alias ArgumentError is thrown.
		 * 
		 * @param	type	the game object type alias.
		 */
		function removeObjectType(type:String):void;
		
		/**
		 * Creates an object of the specified type alias. 
		 * 
		 * @param	type	the alias.
		 * @param	owner	the parent object.
		 * @param	id the identified to be given to the created instance. Null value indicates that identifier would be generated automaticly.
		 * 
		 * @return	an instance of IDisplayObject.
		 */
		function createObject(type:String, owner:ISceneObject = null, id:String = null):Object;
		
		/**
		 * Destroys the object previously created by this factory.
		 * 
		 * @param	o	the object.
		 */
		function releaseObject(o:Object):void;
	}
	
}